include_once("assets/snippets/shoppingCart/kiwee.class.php");
	
$kiwee = new Kiwee();

//[ This array stores all the possible configuration options you can pass to me.  ]
//[ Depending on the function you want to call, just pass me the specified parameters]

$kiweecfg['css'] = (isset($css)) ? $css : null; // [Location of Stylesheet]

$modxtv = $modx->documentObject['ProductNumber'];
$kiweecfg['itemid'] = (isset($itemid)) ? $itemid : $modxtv[1];

$kiweecfg['formid'] = (isset($formid)) ? $formid : 'additemtocart'; // [ Used to tell me what you want the form id to be ]
$kiweecfg['elem'] = (isset($elem)) ? $elem : 'PRICE'; // [Used to tell me what element you want rendered]
$kiweecfg['optname'] = (isset($optname)) ? $optname : 'OPTION'; // [Please send this to me, otherwise generic Option renders (1 - 3) will just display "Option" for a title]
$kiweecfg['multisize'] = (isset($multisize)) ? $multisize : 4;  // [Defaults to 4...feel free to pass me a smaller or larger value depending on what you need]
$kiweecfg['renderas'] = (isset($renderas)) ? $renderas : 'DROP'; // [How you want me to render the option returned DROP | SELECT | MULTI | CHECK ]
$kiweecfg['act'] = (isset($act)) ? $act : '#'; // [Script to process which is sent when you open a form]  Could be another snippet name / call I believe or a backend file]
$kiweecfg['curr'] = (isset($curr)) ? $curr : 'USD'; //[currency support - USD by default and only USD right now...the next version should allow you to define]
$kiweecfg['optionname'] = (isset($optionname)) ? $optionname : $optionname;
$kiweecfg['formname'] = (isset($formname)) ? $formname : 'form1';
$kiweecfg['layout'] = (isset($layout)) ? $layout : 'vertical';
$kiweecfg['contentid'] = (isset($contentid)) ? $contentid : '-1';
     if ($kiweecfg['elem']=='OPTIONS'){
         echo $kiwee->renderOption($kiweecfg['itemid'], $kiweecfg['optionname']);
     }
	 if ($kiweecfg['elem']=='GETCATALOGPRICE'){
	        if ($kiweecfg['contentid']!=-1){
			  $retid = $kiwee->getItemId($kiweecfg['contentid']);
		   	  echo $kiwee->getPrice($retid, $kiweecfg['curr']);
			} else {
			  echo 'Call for information';
			}
	 }
     if ($kiweecfg['elem']=='PRICE') {
         echo $kiwee->getPrice($kiweecfg['itemid'], $kiweecfg['curr']);
      }
     if ($kiweecfg['elem']=='QTY'){
            echo $kiwee->displayQuantity($kiweecfg['itemid']) ;
     }
     if ($kiweecfg['elem']=='OPEN'){
          echo $kiwee->openFormPHP($kiweecfg['itemid'], $kiweecfg['act']);
     }
     if ($kiweecfg['elem']=='CLOSE'){
         echo $kiwee->closeFormPHP();
     }
     if ($kiweecfg['elem']=='CHKOUTBUTTON'){
         echo '<input type="hidden" name="webShortname" id="webShortname" value="' . $_SESSION['webShortname'] . '">' . "\n\n";
         echo '<input type="hidden" name="webInternalKey" id="webInternalKey" value="' . $_SESSION['webInternalKey'] . '">' . "\n\n";
         echo '<input type="hidden" name="webFullName" id="webFullName" value="' . $_SESSION['webFullName'] . '">' . "\n\n"; 
         echo '<input type="hidden" name="webEmail" id="webEmail" value="' . $_SESSION['webEmail'] . '">' . "\n\n";
         echo '<input type="hidden" name="webValid" id="webValid" value="' . $_SESSION['webValid'] . '">' . "\n\n";
         echo '<input type="hidden" name="webUser" id="webUser" value="' . $_SESSION['webUser'] . '">' . "\n\n";
         echo $kiwee->closeFormCheckout();
     }
     if($kiweecfg['elem']=='FINALCHKOUTBUTTON'){
         echo $kiwee->closeFormProcessCheckout();
     }
     if ($kiweecfg['elem']=='VERIFYCHECKOUT'){
         echo '<input type="hidden" id="sessionid" value="' . session_id() . '" />';
         echo $kiwee->closeFormVerifyCheckout();
     }
     if ($kiweecfg['elem']=='SIGNUPBUTTON'){
         echo '<input type="hidden" id="sessionid" value="' . session_id() . '" />';
         echo $kiwee->closeFormSignupForm();
     }
     if ($kiweecfg['elem']=='RETURNBUTTON'){
         echo $kiwee->closeFormReturnButton();
     }
     if($kiweecfg['elem']=='SHOWTAX'){
         echo $kiwee->getTax(session_id());
     }
     if($kiweecfg['elem']=='SHOWSHIP'){
         echo $kiwee->getShip(session_id());
     }
     if($kiweecfg['elem']=='SHOWSUBTOTAL'){
         echo $kiwee->getSubtotal(session_id());
     }
     if($kiweecfg['elem']=='SHOWHANDLE'){
         echo $kiwee->getHandle(session_id());
     }
     if($kiweecfg['elem']=='SHOWTOTAL'){
         echo $kiwee->getTotal(session_id());
     }
     if($kiweecfg['elem']=='FULLNAME'){
         echo $kiwee->getFullname($kiweecfg['itemid']);
     }
     if($kiweecfg['elem']=='DESCRIPTION'){
         echo $kiwee->getDescription($kiweecfg['itemid']);
     }
     if($kiweecfg['elem']=='NAME'){
         echo $kiwee->getName($kiweecfg['itemid']);
     }
     if($kiweecfg['elem']=='JSADDTOCART'){
         echo $kiwee->closeFormJS();
     }
     if($kiweecfg['elem']=='JSOPENFORM'){
         echo $kiwee->openAddItemFormPHP($kiweecfg['formid']);
     }
	 if($kiweecfg['elem']=='OPTIONSAREA'){
	     echo $kiwee->populateOptionsArea($kiweecfg['itemid'], $kiweecfg['layout']);
	 }
